package cn.song.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.song.mapper.UserMapper;
import cn.song.entity.User;
import cn.song.service.UserService;
import org.springframework.stereotype.Service;
import cn.song.common.PageResult;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import cn.song.utils.MybatisPlusUtil;

/**
 * (User)表服务实现类
 *
 * @author Song~
 * @since 2024-06-17 10:38:10
 */
@Service("userService")
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Override
    public PageResult getPage(Integer currentPage, Integer size, User user) {
        Page<User> page = new Page<>(currentPage, size);

        QueryWrapper<User> queryWrapper = MybatisPlusUtil.queryWrapperBuilder(user);

        this.page(page, queryWrapper);

        return new PageResult((int) page.getTotal(), page.getRecords());
    }
}

